program RAITA_24;

{$APPTYPE CONSOLE}

var bc:array['a'..'z']of integer;

function MAX(a,b:integer):integer;
    begin
      if a>b then result := a
        else result := b;
    end;

 procedure OUTPUT(T,p:string;ofset:integer);
   begin
     writeln(T);
     while ofset > 0 do begin
                         write(' ');
                         dec(ofset);
                       end;
     writeln(p);
   end;

  procedure pre_bc(p:string);
      var i,m:integer;
          j:char;
    begin
      m := length(p);
      for j:='a' to 'z' do
        bc[j] := m;
      for i:=1 to m - 1 do
        bc[p[i]]:= m - i;
    end;

  procedure RAITA(T,p:string);
      var n,m,i,j:integer;
          firstCh,middleCh,lastCh,c:char;
    begin
      pre_bc(p);

      n := length(T);
      m := length(p);

      firstCh := p[1];
      middleCh := p[m div 2];
      lastCh:= p[m];

      j:=0;
      while (j<=n-m) do
        begin                    
          //OUTPUT(T,p,j);
          c := T[j + m];
          if (c = lastCh)and(T[j + (m div 2)] = middleCh)and(firstCh = T[j+1]) then
            begin
              i:=2;
              while (i < m)and(T[i+j] = p[i]) do inc(i);
              if i = m then OUTPUT(T,p,j);
              inc(j,bc[p[i]]);
            end else inc(j,bc[c]);
        end;
    end;

begin
  RAITA('gcatcgcagagagtatacagtacg','gcagagag');
  readln;
end.
